function y = GeneralPlotData(path,targetvar,targetana,exclude)

if exist('path','var')
    cd(path)
else
    path = cd;
end

numRuns = length(dir('*.h5'));

if numRuns == 1
    error('Only one measurement in folder, can''t measure temp.')
elseif numRuns == 0
    error('No measurements in folder')
end

cons = Constants();

for n = 1:numRuns-1
    %     n
    if n~=exclude
        img_time = h5read([path '\run_' num2str(n) '.h5'],'/Image/exposuretime');
        img_var = h5read([path '\run_' num2str(n) '.h5'],'/Image/configuration');
        expp = ParamImgSys(GetImgConfig(img_var));
        % Get variable from Cicero
        analog=strcat('/AnalogueMeasurement/',targetana);
        target=strcat('/VariableValues/',targetvar);
        t(n) = double(h5read([path '\run_' num2str(n) '.h5'],target));
        anaparam = double(h5read([path '\run_' num2str(n) '.h5'],analog));
        figure(100)
        plot(anaparam(:,2))
        repumppower(n)=mean(anaparam(6000:6800,2))
        
        yC = 1:1040;
        xC = 1:1392;
        
        [pX,pY] = ProcessImage([path '\run_' num2str(n) '.h5'],1,[1 1392 1 1040],1);
        
        % Estimate number of atoms using camera
        amp = (pX(1) + pY(1))/2; % Take mean amplitude of two Gaussian fits.
        %     capture_fraction = 0.5*(1 - sqrt(1 - (expp.na_telec)^2)); % fraction of total light captured by lens ( ~ 0.5 %)
        total_num_electrons = amp*sqrt(2*pi)*mean([pX(3) pY(3)]);
        total_photons = total_num_electrons/(expp.qe*expp.coll_eff);
        num_atoms(n) = 2*total_photons/(img_time*2*pi*cons.Gamma); % num_atoms = (num_photons/time) / (scattering rate)
        
        % Give the width as the std deviation in m
        px_size = expp.px_size; % m
        mag = expp.mag; % magnification
        wY(n) = pY(3)*px_size/mag; % Std dev in m
        wX(n) = pX(3)*px_size/mag;
        
        posX(n) = pX(2)*px_size/mag;
        posY(n) = pY(2)*px_size/mag;
    end
end

% tt = t.^2;
%
% wYm2 = 2*(wY).^2; % m^2, converted from um.
% wXm2 = 2*(wX).^2;
%
% coeffsY = polyfit(tt(1:end),wYm2(1:end),1);
% coeffsX = polyfit(tt(1:end),wXm2(1:end),1);
%
% v02y = coeffsY(1);
% v02x = coeffsX(1);
%
% m = 86.9*1.66e-27; % mass of Rb87
% k = 1.38e-23;
%
% Tx = v02x*m/(2*k) % K
% Ty = v02y*m/(2*k) % K
%
% r0y = sqrt(coeffsY(2));
% r0x = sqrt(coeffsX(2));

figure(2)
subplot(1,2,1)
plot(repumppower,wY,'.',repumppower,wX,'x')
xlabel(targetvar)
ylabel('Cloud size (m)')
legend('y sigma','x sigma')

subplot(1,2,2)
plot(repumppower,num_atoms,'x')
xlabel(targetvar)
ylabel('Atom number (arb.)')